var provinceArr = ['北京', '上海', '浙江', '江苏'];
var cityArr = [];
cityArr[0] = ['崇文区', '宣武区', '朝阳区'];
cityArr[1] = ['黄浦区', '徐汇区', '长宁区', '静安区'];
cityArr[2] = ['杭州市', '宁波市', '温州市', '嘉兴市', '台州'];
cityArr[3] = ['南京市', '无锡市', '苏州市', '南通市'];

var province=document.getElementById('province');
createProvince(province,provinceArr);
var city=document.getElementById('city');
province.onchange=function(){
	getCity(city,cityArr[province.value]);
}
function createProvince(obj,data){
	for (var i in data){
		var op= new Option(data[i],i);
		obj.options.add(op);
	}
}
function getCity(obj,data){
	obj.options.length=0;
	for (var i in data){
		var op= new Option(data[i],i);
		obj.options.add(op);
	}
	
}
//输入框
var inputs=document.getElementsByTagName('input');
for(var i=0;i<inputs.length;i++){
	inputs[i].onblur=inputBlur;
}
function inputBlur(){
	var name=this.name;
	var value=this.value;
	var tips=this.tips;
	var div=this.parentNode.nextElementSibling.firstChild;
	value=value.trim();
	//判断输入狂是否为空
	if(!value){
		error(div,'输入框不能为空');
		return false;
	}
	var result=getRegMsg(namae,tips);
	if(value.match(result.reg)){
		success(div,result.msg.success);
	}else{
		error(div,result.msg.error);
	}
function getRegMsg(namae,tips){
	var reg=msg='';
	switch(name){
		case'username':
		reg=/^[a-zA-Z]{4,12}$/;
		msg='success'+'用户名正确','error'+tips;
		break;
		case'pwd':
		reg=/^[/w{6,20}]$/;
		msg='success'+'密码输入正确','error'+tips;
		break;
		case'repwd':
		reg=RegExp +'^'+con+'$';
		msg='success'+'两次密码输入正确','error'+'两次密码不一致';
		break;
		case'tell':
		reg=/^1[3457]\d{9}$/;
		msg='success'+'手机号码输入正确','error'+tips;
		break;
	}
	return {'reg':reg,'msg':msg};
}
function error(obj,msg){
	obj.className='error';
	obj.innerHTM=msg;
}
	
}
